package com.ysg.widget.time;

import android.os.CountDownTimer;
import android.widget.TextView;
import com.ysg.R;

public class TimeCountDown extends CountDownTimer {
    private TextView view;

    public TimeCountDown(long millisInFuture, long countDownInterval, TextView view) {
        super(millisInFuture, countDownInterval);
        this.view = view ;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        view.setTextColor(view.getResources().getColor(R.color.codeDisableColor));
        view.setClickable(false);
        view.setText(String.format(view.getResources().getString(R.string.get_code_again), millisUntilFinished / 1000 + ""));
//        view.setText("重新发送("+millisUntilFinished / 1000 +")");
    }

    @Override
    public void onFinish() {
        view.setText(R.string.get_code);
        view.setClickable(true);
        view.setTextColor(view.getResources().getColor(R.color.codeColor));
    }
}
